package com.bot.pms.common.config.dateConverter;

import org.springframework.core.convert.converter.Converter;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

/**
 * LocalDateTime转换器，用于转换RequestParam和PathVariable参数
 */
public class LocalDateTimeConverter  implements Converter<String, LocalDateTime> {

    /**
     * DateTime格式化字符串
     */
    private final String DEFAULT_DATETIME_FORMAT = "yyyy-MM-dd HH:mm:ss";
    @Override
    public LocalDateTime convert(String source) {
        return LocalDateTime.parse(source, DateTimeFormatter.ofPattern(DEFAULT_DATETIME_FORMAT));
    }
}
